﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.IO;

namespace NetWorkSet
{
    public partial class PanelControl : UserControl
    {
        public PanelControl()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 清空文本方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void btnClear()
        {
            switch (this.tabControl1.SelectedTab.TabIndex)
            {
                case 0:
                    this.setControl1.btnClear();
                    break;
                case 1:
                    this.setControl2.btnClear();
                    break;

            }
            
        }
              
        /// <summary>
        /// 应用方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void btnSubmit()
        {
            switch (this.tabControl1.SelectedTab.TabIndex)
            {
                case 0:
                    this.setControl1.btnSubmit();
                    break;
                case 1:
                    this.setControl2.btnSubmit();
                    break;
            }
        }
       
        /// <summary>
        /// 保存配置到XML
        /// </summary>
        public void btnSave()
        {
            switch (this.tabControl1.SelectedTab.TabIndex)
            {
                case 0:
                    this.setControl1.btnSave("SET1",this.tabControl1.SelectedTab.Text);
                    break;
                case 1:
                    this.setControl2.btnSave("SET2", this.tabControl1.SelectedTab.Text);
                    break;
            }
        }

        public void btnCare()
        {
            switch (this.tabControl1.SelectedTab.TabIndex)
            {
                case 0:
                    this.setControl1.btnCare();
                    break;
                case 1:
                    this.setControl2.btnCare();
                    break;
            }
        }

        private void PanelControl_Load(object sender, EventArgs e)
        {
            this.DataLoad();
        }

        public void DataLoad()
        {
            this.SET1.Text = this.setControl1.GetXMLData("SET1");
            this.SET2.Text = this.setControl2.GetXMLData("SET2");
        }

        //获取当前TAB的TEXT值
        public string GetTabTEXT()
        {
            return this.tabControl1.SelectedTab.Text;
        }

        //获取当前TAB的TEXT值
        public string GetTabName()
        {
            return this.tabControl1.SelectedTab.Name;
        }

        //修改当前TAB的TEXT值
        public string SetTabName(string TabName)
        {
           return this.SET1.Text= this.setControl1.GetXMLData(TabName);
        }

        private void tabControl1_Selected(object sender, TabControlEventArgs e)
        {
            Form1 f1=new Form1();
            f1.SetLab(this.tabControl1.SelectedIndex);
        }
    }
}
